package httpService

import (
	"github.com/dchest/captcha"
	"github.com/labstack/echo/v4"
	"log"
)

func Captcha(c echo.Context)error{
	id := c.FormValue("id")
	c.Response().Header().Set("Content-Type", "image/png")

	if err := captcha.WriteImage(c.Response(), id, 120, 60); err != nil {

		log.Println("show captcha error", err)

	}
	return nil
}


func CaptchaId(c echo.Context)error{
	id := captcha.NewLen(4)
	return c.JSON(200, map[string]interface{}{
		"status": 0,
		"data":id,
	})
}

